<?php
$smarty->configLoad($lang . '/donate.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['donate'];
$user = new user;
if(isset($_POST['submit'])) {
	$main->logAction($_SESSION['id'], 'add_donation');
	
	$userID = $user->getID($_POST['username']);
	$sql = 'INSERT INTO '.DB_CMS.'.module_donate (
						userID,
						amount,
						timestamp,
						reason,
						admin,
						coins
						) VALUES (
						:userID,
						:amount,
						CURRENT_TIMESTAMP,
						:reason,
						:admin,
						:coins
						)';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':userID', $userID);
	$dbh->bindValue(':amount', $_POST['amount']);
	$dbh->bindValue(':reason', $_POST['reason']);
	$dbh->bindValue(':admin', $_SESSION['id']);
	$dbh->bindValue(':coins', $_POST['coins']);
	$dbh->execute();
        $user->addCoins($userID, $_POST['coins']);
	$main->jqmodal('addet');
	echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=donate">';

}


$template = 'donate/add.tpl';
?>
